﻿using System;

namespace CommonUtils.Logging.LoggingProviders
{
    /// <summary>
    /// Logging messages to console
    /// </summary>
    public class ConsoleLoggingProvider: BaseLoggingProvider
    {
        #region Constructors

        /// <summary>
        /// Constructor with logging level specification
        /// </summary>
        /// <param name="loggingLevel">Logging level</param>
        public ConsoleLoggingProvider(MessageType loggingLevel): base(loggingLevel)
        {
        }

        /// <summary>
        /// Default constructor
        /// </summary>
        public ConsoleLoggingProvider(): this(MessageType.Output)
        {
        }

        #endregion

        #region Implementation

        /// <summary>
        /// Log message
        /// </summary>
        public override void LogMessageImpl(DateTime dateTime, MessageType messageType, string message)
        {
            Console.WriteLine(string.Format("{0}{1}",
                                            messageType != MessageType.Output ? string.Format("{0}: ", messageType) : "",
                                            message));
        }

        #endregion
    }
}